<template>
  <div class="community views-container">
    <div class="wlm-table">
      <div class="wlm-table-hearder-btn">
        <router-link tag="span" to="/application/leaderManagementAdd">
          <el-button size="small" type="primary">添加团长</el-button>
        </router-link>
      </div>
      <div class="wlm-table-header">
        <el-form :model="tableFormatData.leaderList.files" size="small" label-width="120px" class="retail-form" label-position="right">
          <el-form-item class="filter">
            <el-form-item label="团长名称：" class="search">
              <el-input v-model="tableFormatData.leaderList.files.name" placeholder="请输入名称" style="width:170px;"></el-input>
            </el-form-item>
            <el-form-item label="小区：" class="search">
              <el-input v-model="tableFormatData.leaderList.files.community" placeholder="请输入地址" style="width:170px;"></el-input>
            </el-form-item>
            <el-form-item label="状态：" class="search">
              <el-select v-model="tableFormatData.leaderList.files.status" style="width:170px;">
                <el-option label="正常" :value="2"> </el-option>
                <el-option label="禁用" :value="1"> </el-option>
              </el-select>
            </el-form-item>
            <!-- <el-form-item label="休息状态：" class="search">
              <el-select v-model="tableFormatData.leaderList.files.is_rest" style="width:170px;">
                <el-option label="休息中" :value="1"> </el-option>
                <el-option label="工作中" :value="2"> </el-option>
              </el-select>
            </el-form-item> -->

          </el-form-item>

          <el-form-item label="" class="filter-btns">
            <el-button v-waves type="primary" @click="filesSerch">筛选</el-button>
            <el-button type="text" @click="filesEmpty">清空筛选条件</el-button>
          </el-form-item>
        </el-form>
      </div>
      <div class="wlm-table-content">
        <el-table :ref="tableFormatData.leaderList.key" :data="tableFormatData.leaderList.tableData" @selection-change="handleSelectionChange" style="width: 100%">
          <el-table-column prop="name" label="团长" >
            <template slot-scope="scope">
              <div class="wlm-table-logos flex-row flex-align-c">
                <img class="logo " width="50px" :src="!scope.row.avatarUrl?'https://devwe7.weliam.cn/addons/weliam_areashop/web/assets/store/img/default_avatar.png':scope.row.avatarUrl" style="margin-right:10px;">

                 <div> {{scope.row.name}}</div>
              </div>

            </template>
          </el-table-column>
          <el-table-column prop="phone" label="手机号"></el-table-column>
          <el-table-column prop="goods_num" label="销售商品数">
          </el-table-column>
          <el-table-column prop="address" label="小区">
            <template slot-scope="scope">
              {{scope.row.community}}
            </template>
          </el-table-column>
          <el-table-column label="佣金">
            <template slot-scope="scope">
              <div>总佣金：{{scope.row.sum_reg_money}}</div>
              <div>已提现：{{scope.row.ytx_reg_money}}</div>
              <div>未提现：{{scope.row.wtx_reg_money}}</div>
              <div>提现中：{{scope.row.txz_reg_money}}</div>
            </template>
          </el-table-column>
          <el-table-column prop="status" label="是否禁用">
            <template slot-scope="scope">
              <el-switch v-model="scope.row.status" :active-value="1" :inactive-value="2" @change="changeTableItem({reg_id:scope.row.reg_id,status:scope.row.status},tableFormatData.leaderList.change.status)">
              </el-switch>
            </template>
          </el-table-column>
          <!-- <el-table-column prop="is_rest" label="是否休息">
            <template slot-scope="scope">
              <el-switch v-model="scope.row.is_rest" :active-value="1" :inactive-value="2" @change="changeTableItem({reg_id:scope.row.reg_id,is_rest:scope.row.is_rest},tableFormatData.leaderList.change.is_rest)">
              </el-switch>
            </template>
          </el-table-column> -->
          <el-table-column prop="create_time" label="成为时间">
          </el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <div class="operation-group">
                <router-link class="wlm-text" tag="span" :to="{path:'/application/leaderManagementAdd', query:{reg_id:scope.row.reg_id}}">
                  <el-button type="text">编辑</el-button>
                </router-link>
                <div class="btn-line"></div>
                <el-button class="wlm-text" type="text" @click="delTableItem(scope.row.reg_id)">删除</el-button>
              </div>
            </template>
          </el-table-column>
        </el-table>
        <div class="pagination-content flex-row flex-justify-e flex-align-c">
          <el-pagination :disabled="!hasTableData" @size-change="listPageChange" @current-change="listPageChange" :current-page.sync="tableFormatData.leaderList.pagination.page" :page-sizes="tableFormatData.leaderList.pagination.pagesizes" :page-size.sync="tableFormatData.leaderList.pagination.list_rows" layout="total, sizes, prev, pager, next, jumper" :total="hasTableData?tableFormatData.leaderList.pagination.total : 0">
          </el-pagination>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { reglists, regdel, regeditstatus, regeditisRest } from '@/api/commityBuy'
import waves from '@/directive/waves' // Waves directive
import mixins from '@/mixins/mixins'
export default {
  mixins: [mixins.getters('Table')],
  name: 'Community',
  components: {

  },
  directives: {
    waves
  },
  data() {
    return {
      tableFormatData: {
        current: 'leaderList',
        leaderList: {
          key: 'leaderList',
          api: {
            getList: reglists,
            delList: regdel
          },
          tableData: [],
          files: {
            name: '',
            community: '',
            ids: [],
            status: '',
            is_rest: '',
            checkall: '0'
          },
          rowId: 'reg_id',
          change: {
            status: {
              key: 'status',
              api: regeditstatus
            },
            is_rest: {
              key: 'is_rest',
              api: regeditisRest
            }
          },
          pagination: {
            page: 1,
            list_rows: 10,
            pagesizes: [10, 20, 50],
            total: 0
          }
        }
      }
    }
  },
  methods: {

  }
}
</script>

